package com.shg.bean;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.compass.annotations.Index;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableProperty;
import org.compass.annotations.SearchableReference;
import org.compass.annotations.Store;
/**
 * 标识把当前实体对象设置为搜索实体，但是不是作为搜索的主实体
 * @author admin
 *
 */
@Searchable(root=false)
public class BookType implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//书籍类别ID
	//不需要索引，但是要把他保存起来
	@SearchableProperty(index=Index.NO,store=Store.YES)
	private String id;
	//书籍类别名称(不分词，但要作为索引)
	@SearchableProperty(index=Index.NOT_ANALYZED,store=Store.YES,name="typeName")
	private String name;
	//书籍类别的Logo
	private String logo;
	//书籍类别备注
	private String remark;
	//书籍类别的父类
	private BookType parent;
	//书籍类别的子类
	private Set<BookType> childs;
	//该类别地下的所有书籍
	@SearchableReference
	private Set<Book> book;
	//位列
	private Set<BookType> types=new HashSet<BookType>();
	//伪列
	private String childid;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getLogo() {
		return logo;
	}
	public void setLogo(String logo) {
		this.logo = logo;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public BookType getParent() {
		return parent;
	}
	public void setParent(BookType parent) {
		this.parent = parent;
	}
	public Set<BookType> getChilds() {
		return childs;
	}
	public void setChilds(Set<BookType> childs) {
		this.childs = childs;
	}
	
	public Set<BookType> getTypes() {
		return types;
	}
	public void setTypes(Set<BookType> types) {
		this.types = types;
	}
	public Set<Book> getBook() {
		return book;
	}
	public void setBook(Set<Book> book) {
		this.book = book;
	}
	public String getChildid() {
		return childid;
	}
	public void setChildid(String childid) {
		this.childid = childid;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BookType other = (BookType) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
}
